﻿namespace OverStore.Exceptions
{
    using System;

    /// <summary>
    /// Exception that is thrown when persistence operation like loading or saving collection, instance,
    /// creating or iterating object reader failed because of underlying error.
    /// </summary>
    public sealed class PersistenceOperationFailedException : Exception
    {
        /// <summary>
        /// Initializes new instance of <see cref="PersistenceOperationFailedException"/> class.
        /// </summary>
        public PersistenceOperationFailedException()
        {
        }

        /// <summary>
        /// Initializes new instance of <see cref="PersistenceOperationFailedException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public PersistenceOperationFailedException(string message)
            : base(message)
        {
        }

        /// <summary>
        /// Initializes new instance of <see cref="PersistenceOperationFailedException"/> class.
        /// </summary>
        /// <param name="message">The error message that explains the reason for the exception.</param>
        /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
        public PersistenceOperationFailedException(string message, Exception innerException)
            : base(message + Environment.NewLine + innerException.Message, innerException)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="PersistenceOperationFailedException"/> class.
        /// </summary>
        /// <param name="ex">The inner exception.</param>
        public PersistenceOperationFailedException(Exception ex)
            : base(ex.Message, ex)
        {
        }
    }
}